package com.sf.bigscreen.controller;

import com.sf.bigscreen.entity.Result;
import com.sf.bigscreen.service.IDayAmService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: bi xuan
 * @Date: 2021/7/8 16:55
 * @Description:
 **/
@Api(tags="关于电表信息的参数接口")
@RestController
@RequestMapping("/dayAm")
public class DayAmController {
    @Autowired
    private IDayAmService dayAmService;

    @ApiOperation("同步一段时间的全校电费数据")
    @GetMapping("/updateDayAmAll")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayAmAllInfo(@RequestParam("dateStart") String dateStart,@RequestParam("dateEnd") String dateEnd){
        dayAmService.addOrUpdateDayAmAllInfoRangeTime(dateStart,dateEnd);
        return Result.buildSuccessMessage("同步一段时间的全校电费数据成功");
    }

    @ApiOperation("同步一段时间的区域电费数据")
    @GetMapping("/updateDayAmArea")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "areaId", value = "区域id", dataType = "int", paramType = "query", example = "1", required = true),
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayAmAreaInfo(@RequestParam("areaId") Integer areaId,@RequestParam("dateStart") String dateStart,@RequestParam("dateEnd") String dateEnd){
        dayAmService.addOrUpdateDayAmAreaInfoRangeTime(areaId, dateStart, dateEnd);
        return Result.buildSuccessData(1);
    }

    @ApiOperation("同步一段时间的建筑电费数据")
    @GetMapping("/updateDayAmArc")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "arcId", value = "建筑id", dataType = "int", paramType = "query", example = "1", required = true),
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayAmArcInfo(@RequestParam("arcId") Integer arcId,@RequestParam("dateStart") String dateStart,@RequestParam("dateEnd") String dateEnd){
        dayAmService.addOrUpdateDayAmArcInfoRangeTime(arcId, dateStart, dateEnd);
        return Result.buildSuccessMessage("同步一段时间的建筑电费数据");
    }

    @ApiOperation("同步一段时间的部门电费数据")
    @GetMapping("/updateDayAmPart")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "departmentId", value = "部门id", dataType = "int", paramType = "query", example = "1", required = true),
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayAmPartInfo(@RequestParam("departmentId") Integer departmentId,@RequestParam("dateStart") String dateStart,@RequestParam("dateEnd") String dateEnd){
        dayAmService.addOrUpdateDayAmDepartmentInfoRangeTime(departmentId, dateStart, dateEnd);
        return Result.buildSuccessMessage("同步一段时间的部门电费数据");
    }

    @ApiOperation("同步一段时间的单只电表电费数据")
    @GetMapping("/updateDayAmMeter")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "meterId", value = "电表id", dataType = "int", paramType = "query", example = "1", required = true),
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayAmMeterInfo(@RequestParam("meterId") Integer meterId,@RequestParam("dateStart") String dateStart,@RequestParam("dateEnd") String dateEnd){
        dayAmService.addOrUpdateDayAmInfoRangeTime(meterId, dateStart, dateEnd);
        return Result.buildSuccessMessage("同步一段时间的单只电表电费数据");
    }
}
